<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>


<%
    if (session.getAttribute("loggedIn") != null) 
    {
        if (((Boolean) session.getAttribute("loggedIn"))) 
        {
            if (session.getAttribute("role").equals("courier")) 
            {
                response.sendRedirect("courier_shipments.jsp");
            } 
            else if (!session.getAttribute("role").equals("admin")) 
            {
                response.sendRedirect("index.jsp");
            }
        } else {
            response.sendRedirect("index.jsp");
        }
    } else {
        response.sendRedirect("index.jsp");
    }
%>

<s:layout-render name="/managerlayout.jsp" headline="Delivery Service">

    <s:layout-component name="body">
        <s:useActionBean var="actionBean" beanclass="cz.muni.fi.pa165.web.ManagerShipmentActionBean"/>
        <h2 style="text-align: center;"><f:message key="ManagerNEWShipmentHeadline"/></h2>
        <s:form style="padding-left: 28%; padding-top: 5%;" action="/Manager-Shipment.add">
            <s:errors/> 
                <table>
                    <tr>
                        <th style="text-align: left;"><f:message key="Manager-Shipment-list-sender"/></th>
                        <td style="padding-left: 5%;"><s:select name="senderID"><s:options-collection collection="${actionBean.customers}" value="id" label="firstName"/></s:select></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="Manager-Shipment-list-recipient"/></th>
                        <td style="padding-left: 5%;"><s:select name="recipientID"><s:options-collection collection="${actionBean.customers}" value="id" label="firstName"/></s:select></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="Manager-Shipment-list-courier"/></th>
                        <td style="padding-left: 5%;"><s:select name="courierID"><s:options-collection collection="${actionBean.couriers}" value="id" label="firstName"/></s:select></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="Manager-Shipment-list-tarrif"/></th>
                        <td style="padding-left: 5%;"><s:select name="tarrifID"><s:options-collection collection="${actionBean.tarrifs}" value="id" label="name"/></s:select></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="Manager-Shipment-list-shipmentState"/></th>
                        <td style="padding-left: 5%;"><s:text id="shipmentState" name="shipment.shipmentState"/></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="Manager-Shipment-list-weight"/></th>
                        <td style="padding-left: 5%;"><s:text id="weight" name="shipment.weight"/></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="Manager-Shipment-list-distance"/></th>
                        <td style="padding-left: 5%;"><s:text id="distance" name="shipment.distance"/></td>
                    </tr>
                    <tr>
                        <th style="text-align: left;"><f:message key="Manager-Shipment-list-description"/></th>
                        <td style="padding-left: 5%;"><s:text id="description" name="shipment.description"/></td>
                    </tr>
                    <tr>
                        <th><s:label for="save" name=" "/></th>
                        <td style="padding-left: 5%;"><s:submit class="btn btn-block" name="save"><f:message key="Manager-Shipment-list-SAVE"/></s:submit></td>
                    </tr>
                </table>
        </s:form>
    </s:layout-component>
</s:layout-render>
